﻿using RTW.Core.Datas;
using RTW.Core.Ioc;
using RTW.Models;
using System;
using System.Collections.Generic;
using System.Text;

namespace RTW.Servers
{
    public class TMsgServer : BaseDAL<TMsg>, IAutoInject
    {
        public List<TMsg> GetMsgsByUser(string userID)
        {
            return DbType.DB().Select<TMsg>().Limit(10)
                  .LeftJoin(a => a.User1.ID == a.UserID1)
                  .LeftJoin(a => a.User2.ID == a.UserID2)
                  .Where(m => (m.UserID2 == userID && m.State ==0))
                  .OrderByDescending(m=>m.AddTime)
                  .ToList<TMsg>();
        }
    }
}
